<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page autoFlush="true" buffer="1024kb"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>车辆基础资料</title>
<link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/CSS/bombBox.css">
<%-- <link href="<%=path%>/CSS/style.css" rel="stylesheet" type="text/css" /> --%>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/carListPage.jsp"%> 
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/departmentListPage.jsp"%>
	<%@ include file="/WEB-INF/JSP/ajax.jsp"%>
<style type="text/css">
	.seachform li label{line-height: 45px;color: #444444}
	.scinput{line-height: 10px;margin-top: 5px}
	.scinput1{margin-top: 5px;height: 30px;}
	.scbtn{background: #57a0ff;border-radius:20px;width: 110px;margin-top: 4px;height: 35px;outline:none;}
	.scbtn2{height: 20px;background: #57a0ff;border-radius:20px;width: 50px;color: #fff;display: none;}

	thead {background: #f2f2f2}
	tbody tr:nth-child(even) {background: #f7f8fd}
	.tablelist th{height: 45px;padding-left: 30px;text-align: center;background: none;border-bottom: none;}
	.tablelist td{border-right:none;padding-left: 30px;text-align: center;}
	tbody tr{height: 38px}
	.check{padding-left: 0px}
	a{cursor: pointer;}
	.placeul a{color: #444444}
	.success td{border-left:1px solid #dddee6;
		border-right: 1px solid #dddee6;}
	.seachform{display: block; list-style-type: disc; -webkit-margin-before: 1em; -webkit-margin-after: 1em; -webkit-margin-start: 0px; -webkit-margin-end: 0px; -webkit-padding-start: 40px;}
	.seachform { display: block; margin: 0; padding: 0; list-style: none; border-bottom:none }
	.rightinfo { padding: 8px; font-size: 12px}
	/* * { border: 0; margin: 0; padding: 0; } */
	.scbtn { background: #57a0ff; border-radius: 20px; width: 110px; margin-top: 4px; height: 35px; outline: none;border: 0 }
	.scbtn { width: 95px; height: 34px;  font-size: 14px; font-weight: bold; color: #fff; cursor: pointer; border-radius: 50px; behavior: url(js/pie.htc);}
	.scinput { width: 150px; height: 30px; line-height: 30px; border-top: solid 1px #a7b5bc; border-left: solid 1px #a7b5bc; border-right: solid 1px #ced9df; border-bottom: solid 1px #ced9df; background: url(../images/inputbg.gif) repeat-x; text-indent: 10px; }
	a, a:focus { text-decoration: none; color: #000; outline: none; blr: expression(this.onFocus=this.blur()); }
	.seachform li { float: left; margin-right: 15px; }
	li { display: block; margin: 0; padding: 0; list-style: none; }
	.scinput1 { width: 150px; height: 30px; line-height: 30px; border-top: solid 1px #a7b5bc; border-left: solid 1px #a7b5bc; border-right: solid 1px #ced9df; border-bottom: solid 1px #ced9df; background: url(../images/inputbg.gif) repeat-x; text-indent: 10px; }
	.placeul li:last-child { background: none; }
	.seachform li label{margin-right: 10px}
	.placeul li { float: left; line-height: 40px; padding-left: 7px; padding-right: 12px; background: url(../images/rlist.gif) no-repeat right;font-size: 9px }
	ul{border-bottom: none;}
	.findBtn, .findBtn1, .findBtn2:hover {
		background: -webkit-linear-gradient(top, #8DC9EF, #4E9FD1);
		background: -moz-linear-gradient(top, #8DC9EF, #4E9FD1);
		background: linear-gradient(top, #8DC9EF, #4E9FD1);
		background: -ms-linear-gradient(top, #8DC9EF, #4E9FD1);
	}
	.findBtn, .findBtn1, .findBtn2 {
		background: #427dff, background;
		border-radius: 50px;
		background: -webkit-linear-gradient(top, #57a0ff, #57a1ff);
		background: -moz-linear-gradient(top, #57a0ff, #57a1ff);
		background: linear-gradient(top, #57a0ff, #57a1ff);
		background: -ms-linear-gradient(top, #57a0ff, #57a1ff);
		border: 1px solid #2576A8;
		box-shadow: 0 1px 2px #8AC1E2 inset, 0 -1px 0 #57a0ff inset;
		color: #fff;
		height: 40px;
		text-shadow: 1px 1px 0.5px #57a0ff;
		outline: none;
		margin-left: 100px;
	}
</style>
</head>
<body style="background: #f5f5f5;padding: 0 10px;">
		<div class="place" style="background: #f5f5f5;margin-top: 10px">
			<ul class="placeul">
				<li><a href="#">报表</a></li>
				<li><a href="#">车辆维修报表</a></li>
			</ul>
		</div>
	
		<div class="rightinfo" style="background: #fff;border-radius:10px;min-height: 45px;float: left;margin-bottom: 20px;width:99.1%">
			<form action="<%=path%>/DrivingSys/selCarMaintainJournalByCon" method="post">
				<ul class="seachform" >
					    <li><label>车辆</label><input name="cfcarName" id="car" type="text" class="scinput" value="${carmaintainentry.cfcarName}"/>
					    <input type="hidden"  name="cfcarnoid" class="car" value="${carmaintainentry.cfcarnoid}" >
					    </li>
					    <li><label>部门</label>
					    <input  id="deparment" name="cfdepartmentName" type="text" class="scinput" value="${carmaintainentry.cfdepartmentName}"/>
					     <input type="hidden"  name="deparmentId" class="deparment" value="${deparmentId}" >
					    </li>
					    <li><label>维修类型</label>
					    <select style="height: 34px;width: 152px" name="cfmaintetype">
					    <c:choose>
					    	<c:when test="${carmaintainentry.cfmaintetype eq 1}">
					    			<option></option>
					    			<option selected="selected" value="1" >正常维修</option>	
					    			<option value="2">事故维修</option>
					    			<option value="3">公交车维修</option>
					    	</c:when>
					    	<c:when test="${carmaintainentry.cfmaintetype eq 2}">
					    			<option></option>
					    			<option  value="1" >正常维修</option>	
					    			<option selected="selected" value="2">事故维修</option>
					    			<option value="3">公交车维修</option>
					    	</c:when>
					    	<c:when test="${carmaintainentry.cfmaintetype eq 3}">
					    			<option></option>
					    			<option  value="1" >正常维修</option>	
					    			<option  value="2">事故维修</option>
					    			<option  selected="selected"value="3">公交车维修</option>
					    	</c:when>
					    	<c:otherwise>
					    			<option selected="selected" ></option>
					    			<option  value="1" >正常维修</option>	
					    			<option  value="2">事故维修</option>
					    			<option  value="3">公交车维修</option>
					    	</c:otherwise>
					    </c:choose>
					    </select>
					    </li>			    
					   <li><label>开始时间</label><input class="scinput1"  name="beginTime" type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}',dateFmt:'yyyy-MM-dd'})"
					    id="datemin" class="input-text Wdate" style="width:150px;" value="${beginTime}"></li>
						<li><label>结束时间</label><input class="scinput1"  name="endTime" type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'})"
						id="datemax" class="input-text Wdate" style="width:150px;"value="${endTime}"></li>		
						<li><label>&nbsp;</label><input name="" type="submit"  style="outline: none;"  class="scbtn" value="立即查询" /></li>
					<shiro:hasPermission name="/selCarMaintainJournalByCon">
						<label>&nbsp;</label>
						<li style="height: 40px;text-align: left;color: #999999;">
				       &nbsp;<input   type="button"  id="submitExcel"  value="导出EXCLE" class="scbtn" >
							</li>
					</shiro:hasPermission>
				</ul>
			
			</form>
		</div>
		
		
		<div style="width: 100%;overflow:auto;margin-bottom: 0px;margin-top: 30px;background: #fff;border-radius:10px;min-height:600px">
		<form id="excel" action="<%=path%>/DrivingSys/outXls" method="post">
			<div class='loading'>
			
			</div>
		<div  class="success">
		
						<div style="min-height: 240px;width: 85%;padding-left: 20px;padding-top: 20px;">
						
								<table  width="100%" align="center" id="table"  style="border-collapse:collapse;min-height:30px;border-spacing:0;display: none;">
									<thead>
									<td height="55px" style="font-size: 18px;text-align: center;color: black" colspan="8">
										${beginTime} 至 ${endTime} 车辆维修报表
									</td>
									</thead>
									<thead>
										<td style="width: 5px;height: 50px;background: rgb(228,234,254);"></td>
										<td style="width: 27px;height: 50px;background: rgb(228,234,254);"  align="center">部门</td>
										<td style="height: 51px;width:35px;background: rgb(228,234,254);" align="center">车辆</td>
										<td style="width: 25px;height: 50px;background: rgb(228,234,254);" align="center">维修类型</td>
										<td style="width: 23px;height: 50px;background: rgb(228,234,254);" align="center">维修金额</td>
										<td style="width: 23px;height: 50px;background: rgb(228,234,254);" align="center">工时金额</td>
										<td style="width: 24px;height: 50px;background: rgb(228,234,254);" align="center">总金额</td>
									</thead>
									<c:forEach items="${carmaintainentries}" var="carmaintainentry"> 
									<tr style="border-left: 1px solid #c7c7c7;" id="two" >
										<td width="20px"></td>
										<td style="width: 20px;text-align: center;" align="center">${carmaintainentry.cfdepartmentName}</td>
										<td style="width: 20px;text-align: center;" align="center">${carmaintainentry.cfcarName}</td>
										<c:if test="${carmaintainentry.cfmaintetype eq 1}">
						                    <td align="center">正常维修</td>
						                </c:if>
						                <c:if test="${carmaintainentry.cfmaintetype eq 2}">
						                    <td align="center">事故维修</td>
						                </c:if>
						                <c:if test="${carmaintainentry.cfmaintetype eq 3}">
						                    <td align="center">公交车维修</td>
						                </c:if>
										<td style="width: 20px;text-align: center;" align="center">${carmaintainentry.cfprice*carmaintainentry.cfqty}</td>
										<td style="width: 20px;text-align: center;" align="center">${carmaintainentry.cfbasemanhours}</td>
										<td style="width: 20px;text-align: center;" align="center">${carmaintainentry.cfallamount}</td>								
									</tr>
									</c:forEach>				
									<tr class="endRow" >
										<td style="width: 10px;background: rgb(255,193,133);text-align: center;"></td>
										<td style="width: 20px;background: rgb(255,193,133);text-align: center;" align="center">总计</td>
										<td style="width: 20px;background: rgb(255,193,133);text-align: center;" align="center"></td>
										<td style="width: 20px;background: rgb(255,193,133);text-align: center;" align="center"></td>
										<td style="font-weight: 800;width: 20px;background: rgb(255,193,133);text-align: center;" align="center">${carmaintainentrys.cfprice}</td>
										<td style="font-weight: 800;width: 20px;background: rgb(255,193,133);text-align: center;" align="center">${carmaintainentrys.cfbasemanhours}</td>
										<td style="font-weight: 800;width: 20px;background: rgb(255,193,133);text-align: center;" align="center">${carmaintainentrys.cfallamount}</td>
									</tr>
								</table>
								
								<input id="xls" type="hidden" name="xls" value="">
                				<input type="hidden" value="车辆维修报表" name="fileNames">
								
						</div>
				</div>		
				 </form>
		</div>



		
</body>

<script type="text/javascript">

		$(".scbtn").live('click',function () {
			if($('#car').val() == '')
				$('.car').val("")
			if($('#deparment').val() == '')
				$('.deparment').val("")
		})

        $('#submitExcel').live('click',function () {
            $('#excel').submit()
        })

		$(document).ready(function(){
			

			
			function _w_table_rowspan(_w_table_id,_w_table_colnum){     
	            _w_table_firsttd = "";     
	            _w_table_currenttd = "";     
	            _w_table_SpanNum = 0;     
	            _w_table_Obj = $(_w_table_id + " tr td:nth-child(" + _w_table_colnum + ")");     
	            _w_table_Obj.each(function(i){     
	                if(i==0){     
	                    _w_table_firsttd = $(this);     
	                    _w_table_SpanNum = 1;     
	                }else{     
	                    _w_table_currenttd = $(this);     
	                    if(_w_table_firsttd.text()==_w_table_currenttd.text()){     
	                        _w_table_SpanNum++;     
	                        _w_table_currenttd.remove(); //remove();     
	                        _w_table_firsttd.attr("rowSpan",_w_table_SpanNum);     
	                    }else{     
	                    	var str1 = ''
	                    	str1='<tr><td style="text-align: center; width: 2px;" class="xuhao"></td>'
		    	    			str1+='<td style="text-align: center; width: 20px;background: rgb(250,255,203);" >小计</td>'
		        	    		str1+='<td style="text-align: center; width: 10px;background: rgb(250,255,203);" ></td>'
		        	    			str1+='<td style="text-align: center; width: 10px;background: rgb(250,255,203);" ></td>'
		        	    				str1+='<td style="font-weight: 800;text-align: center; width: 10px;background: rgb(250,255,203);" ></td>'
		        	    						str1+='<td style="font-weight: 800;text-align: center; width: 10px;background: rgb(250,255,203);" ></td>'
			    	    		str1+='<td style="font-weight: 800;text-align: center; width: 10px;background: rgb(250,255,203);" class="num_department"></td></tr>'
			    	    		if(_w_table_SpanNum == 1){		            		
				    	             $(this).parent().prev().after(str1)	 
				            	}
			    	    		if(_w_table_SpanNum != 1){
			    	    			$(this).parent().prev().after(str1)	
			    	    		}   
	                        _w_table_firsttd = $(this);     
	                        _w_table_SpanNum = 1;     
	                    }     
	                }     
	            });      
	            $('#table').show()
				$('.loading').hide()
	 }     
			
			  
			 /* _w_table_rowspan_two("#table", "3","0")   */
			
		    
		    _w_table_rowspan("#table", "2")   
		    
		    

			 totalPrice = 0   //部门小计
			 totalCount = 0   //合计金额
			 hourPrice = 0	 //工时金额
			 hourCount = 0	 //工时合计
			 tainPrice = 0
			 tainCount = 0
		    $('#table tr:not(:first)').each(function(i){
		    	if(i == 0){}
		    	else{
		    		$('.endRow').nextAll().remove()
				if($(this).find('td:eq(1)').html() == '小计'){
					totalPrice = totalPrice.toFixed(2)
					hourPrice = hourPrice.toFixed(2)
					tainPrice = tainPrice.toFixed(2)
					$(this).find("td:last").html(totalPrice)
					$(this).find("td:last").prev().html(hourPrice)
					$(this).find("td:last").prev().prev().html(tainPrice)
					/* totalCount = (totalCount-0) + (totalPrice-0);
					hourCount = (hourCount-0) + (hourPrice-0)
					tainCount = (tainCount-0) + (tainPrice-0) */
					totalPrice = 0
					tainPrice = 0
					hourPrice = 0
				}else{
			    		totalPrice = totalPrice.toFixed(2)
			    		/* hourPrice = hourPrice.toFixed(2) */
						/* tainPrice = tainPrice.toFixed(2) */
						totalPrice = (totalPrice-0) +($(this).find("td:last").html()-0)
						hourPrice = (hourPrice-0) + ($(this).find("td:last").prev().html()-0)	
						tainPrice = (tainPrice-0) + ($(this).find("td:last").prev().prev().html()-0)

					}
				} 

			})
		    
		 
			
			$('#car').click(function(e){
				$('#modal-overlay').css('visibility','visible') 
				$('.modal-data5').css('visibility','visible')
				$('input:checkbox').removeAttr('checked');	
				_this =$(this).parent().parent();
			})
			
			$('#deparment').click(function(e){
				$('#modal-overlay').css('visibility','visible') 
				$('.modal-data6').css('visibility','visible')
				$('input:checkbox').removeAttr('checked');
				_this =$(this).parent();
			})
			
			
			
			
			
			$('#subtn6').click(function(){
				   var dep = $('input:checkbox[name=train3]:checked').parent()

			        /*_this.children().children('input[class=carName]').val(car.next().html());
			         _this.children().children('input[class=cfcarid]').val($('input:checkbox[name=train]:checked').val());
			         _this.children().children('input[class=cfcarno]').val(car.next().next().html());*/
			        $('#deparment').val(dep.next().next().html())
					$('.deparment').val($('input:checkbox[name=train3]:checked').val())
			        $('#modal-overlay').css('visibility', 'hidden')
			        $('.modal-data6').css('visibility', 'hidden')
			        $('input:checkbox[name=train3]:checked').removeAttr("checked");

			})
			
			$('#subtn5').click(function(){
				   var dep = $('input:checkbox[name=train]:checked').parent()

			        /*_this.children().children('input[class=carName]').val(car.next().html());
			         _this.children().children('input[class=cfcarid]').val($('input:checkbox[name=train]:checked').val());
			         _this.children().children('input[class=cfcarno]').val(car.next().next().html());*/
			         $('#car').val(dep.next().html())
			         $('.car').val($('input:checkbox[name=train]:checked').val())
			        $('#modal-overlay').css('visibility', 'hidden')
			        $('.modal-data5').css('visibility', 'hidden')
			        $('input:checkbox[name=train3]:checked').removeAttr("checked");

			})
			
			$('.btn').click(function () {
		    $('#modal-overlay').css('visibility', 'hidden')

		    $('.modal-data5').css('visibility', 'hidden')
		    $('.modal-data6').css('visibility', 'hidden')
		    $('.data-checkbox:checkbox').removeAttr('checked');
		    $('.data1-checkbox:checkbox').removeAttr('checked');
		    $('.data2-checkbox:checkbox').removeAttr('checked');
		    $('.data3-checkbox:checkbox').removeAttr('checked');
		    $('.data4-checkbox:checkbox').removeAttr('checked');
		    $('.data5-checkbox:checkbox').removeAttr('checked');
		    $('.page').hide();
		})
		$('#xls').val($('.success').html());
		  
	    })
		
</script>

</html>
